package de.playmee.dialogs;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;

public class CustomDialog {

	// private final String TAG = "CustomDialog";
	
	/**
	 * shows a neutral dialog with information icon
	 */
	public static void showInfoDialog(Context context, String title, String message) {
		showNeutralDialog(context, title, message, android.R.drawable.ic_dialog_info);
	}
	
	/**
	 * shows a neutral dialog with alert icon
	 */
	public static void showAlertDialog(Context context, String title, String message) {
		showNeutralDialog(context, title, message, android.R.drawable.ic_dialog_alert);
	}
	
	/**
	 * shows a dialog with title, message, icon and neutral button
	 */
	public static void showNeutralDialog(Context context, String title, String message,
			int imageResourceId) {
		OnClickListener onClickListener = new OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
				dialog.cancel();
			}
		};
		showNeutralDialog(context, title, message, imageResourceId, onClickListener);
	}
	
	/**
	 * shows a dialog with title, message, icon and neutral button
	 */
	public static void showNeutralDialog(Context context, String title, String message,
			int imageResourceId, OnClickListener onClickListener) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setIcon(imageResourceId);
		builder.setTitle(title);
		builder.setMessage(message);
		
		builder.setNeutralButton("OK", new OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
				dialog.cancel();
			}
		});
		
		AlertDialog alert = builder.create();
		alert.show();
	}
}
